#include <iostream>
#include <cstdio>
using namespace std;
#include <unistd.h>
#include <signal.h>

void handler(int signo)
{
    cout<<"get a signo: "<<signo<<"正在处理中..."<<endl;
    int cnt = 20;
    while(cnt)
    {
        printf("cnt: %2d\r",cnt);
        fflush(stdout);
        cnt--;
        sleep(1);
    }
    printf("\n");
}
int main()
{
    struct sigaction act,oldact;
    sigset_t mask;
    sigemptyset(&mask);
    sigaddset(&mask,3);
    act.sa_handler = handler;
    act.sa_mask = mask;
    act.sa_flags = 0;
    sigaction(SIGINT,&act,&oldact);

    while(true)sleep(1);
    return 0;
}